using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.Proxies.LazyProxyHelper
{
    [TestClass]
    public class WhenCreating
    {
        [TestMethod]
        public void ShouldNotExecuteWhenNotRequired()
        {
            string expectedParameter = "x";
            Order expectedResult = new Order(1, new List<Amount>(new Amount[] {new Amount(1)}));

            Be.Timvw.Framework.Proxies.LazyProxyHelper.Create<Order, string>(delegate(string actualParameter)
            {
                Assert.AreEqual(expectedParameter, actualParameter);
                Assert.Fail("Should not perform this method.");
                return expectedResult;
            }, expectedParameter);
        }

        [TestMethod]
        public void ShouldExecuteWhenRequired()
        {
            string expectedParameter = "x";
            Order expectedResult = new Order(1, new List<Amount>(new Amount[] {new Amount(1)}));

            Order actualResult = Be.Timvw.Framework.Proxies.LazyProxyHelper.Create<Order, string>(delegate(string actualParameter)
            {
                Assert.AreEqual(expectedParameter, actualParameter);
                return expectedResult;
            }, expectedParameter);

            Assert.AreEqual(expectedResult.Id, actualResult.Id);
            Assert.AreEqual(expectedResult.Amounts, actualResult.Amounts);
        }
    }
}